package com.mq.common;

import javax.servlet.ServletContextEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.util.WebUtils;

/**
 * 监视ServletContext以做相应的初始化和销毁工作
 * 
 * @author chenbb
 */
public class ServletContextListener implements javax.servlet.ServletContextListener
{
	@Override
	public void contextInitialized(ServletContextEvent event)
	{
		WebUtils.setWebAppRootSystemProperty(event.getServletContext());
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
	}
   @Override
	public void contextDestroyed(ServletContextEvent event)
	{
		WebUtils.removeWebAppRootSystemProperty(event.getServletContext());
	}
}
